//package net.flydy.ywxcx.wxcloudrun.controller;
//
//import cn.hutool.core.util.HexUtil;
//import lombok.extern.slf4j.Slf4j;
//import net.flydy.ywxcx.wxcloudrun.common.*;
//import net.flydy.ywxcx.wxcloudrun.model.*;
//import net.flydy.ywxcx.wxcloudrun.dto.*;
//import net.flydy.ywxcx.wxcloudrun.service.impl.*;
//import net.flydy.ywxcx.wxcloudrun.vo.*;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.HashMap;
//import java.util.Objects;
//
//@Controller
//@Slf4j
//@RequestMapping(value = "/admin/")
//public class AdminController extends BaseController {
//
//    private static final String LogPre = "/admin";
//
//    @Autowired
//    private AdminService adminService;
//
//    @RequestMapping(value = {"/doLogin"},
//            produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public BaseResponse doLogin(HttpServletRequest httpReq, HttpServletResponse httpResp, @RequestBody AdminLoginRequest request) {
//
//        String interfaceType = LogPre + "/doLogin";
//        BaseDTO<AdminLoginRequest, BaseResponse> dto = new BaseDTO<>();
//        dto.setReqInterface(interfaceType);
//        dto.setRequest(request);
//        String reqIp = Utils.getIp(httpReq);
//        dto.setReqIp(reqIp);
//        return doService(()->{
//            String account = request.getLoginId();
//            String pwd = request.getPwd();
//            BaseException.checkAndThrow(StringUtils.isNotBlank(account), StatusEnum.VALIDATION_FAIL.code(), null);
//            BaseException.checkAndThrow(StringUtils.isNotBlank(pwd), StatusEnum.VALIDATION_FAIL.code(), null);
//            Myadmin adminaccountDO = adminService.findAdmin(account);
//            BaseException.checkAndThrow(adminaccountDO != null && Objects.equals(adminaccountDO.getStatus(), 1), StatusEnum.NO_RESOURCE.code(), null);
//            String pwddb = adminaccountDO.getPwd();
//            String md5Pwd = HexUtil.encodeHexStr(EncryptUtils.md5(pwddb.getBytes()));
//            BaseException.checkAndThrow(StringUtils.equalsIgnoreCase(pwd, md5Pwd), StatusEnum.ACCOUNT_NOT_MATCH.code(), null);
//            String token = adminService.genToken(adminaccountDO,3600 * 48 * 1000);
//            HashMap bodyData = new HashMap();
//            bodyData.put("token", token);
//            bodyData.put("id", adminaccountDO.getId());
//            BaseResponse baseResponse = BaseResponse.getSuccessInstance();
//            baseResponse.setDataBody(bodyData);
//            return baseResponse;
//        }, dto);
//    }
//
//    @RequestMapping(value = {"/myInfo"},
//            produces = "application/json;charset=utf-8",
//            method = {RequestMethod.POST})
//    @ResponseBody
//    public BaseResponse myInfo(HttpServletRequest httpReq, HttpServletResponse httpResp,  @RequestBody String request) {
//        return BaseResponse.getSuccessInstance();
//    }
//}
